﻿using Irony.Parsing;
using NMF.Languages.AnyText.ClassConstruction;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NMF.Languages.AnyText
{
    public class IntegerTypeTerminal : DataTypeTerminal<IntegerType>
    {
        protected IntegerTypeTerminal(string name, IntegerType type)
            : base(name, type)
        {

        }

        public IntegerTypeTerminal(string name) : this(name, new IntegerType()) { }

        public override DataTypeTerminal<IntegerType> CreateCustom()
        {
            return new IntegerTypeTerminal("CustomInteger", new IntegerType());
        }

        public override BnfExpression CreateRule(AnyTextGrammar grammar)
        {
            var intNumber = new NumberLiteral("IntNumber", NumberOptions.IntOnly);
            intNumber.DefaultIntTypes = new TypeCode[] { TypeCode.Int32 };
            intNumber.AddPrefix("0x", NumberOptions.Hex);
            return intNumber;
        }
    }
}
